import numpy as np


# 计算两点之间的欧几里得距离
def euclidean_distance(point1, point2):
    return np.sqrt(np.sum((point1 - point2) ** 2))


# 定义出发点和终点
start_points = np.array([[0, 0], [0, 5], [5, 5], [5, 0]])
end_points = np.array([[1, 1], [4, 1], [1, 4], [4, 4]])

# 计算每个终点到起点的距离  
distances = np.array([euclidean_distance(start, end) for start in start_points for end in end_points])

# 使用距离排序终点  
sorted_indices = np.argsort(distances)[::-1]  # [::-1]用于降序排序  
sorted_endpoints = end_points[sorted_indices]

print(sorted_endpoints)